
    

function yanzhengma(){
    	   var phone=$("#phone").val();
    	   
    	 if (!(/^1(3|4|5|7|8)\d{9}$/.test(phone))){ 
	            	alert("手机号码有误");
	            	return;
	       }else{
	       	
	       	$.ajax({   
 url: urlcore + "/api/user/getPhoneCode?type=1&phone="+phone,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
                    alert("请注意查收");      
				} else {
				alert("error1");
				}
			},
			error: function() {
				alert("error");
			}
		});
	       }
    }

   function queding(){
    	  var phone=$("#phone").val();
    	  var code=$("#code").val();
    	 if (!(/^1(3|4|5|7|8)\d{9}$/.test(phone))){ 
	            	alert("手机号码有误");
	            	return;
	       }else{
	       	
	       	$.ajax({
 url: urlcore + "/api/user/updatePhone?phone="+phone+"&code="+code,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
						
                alert("成功！！");        
              //loginout();
                
				} else {
				alert("error1");
				}
			},
			error: function() {
				alert("error");
			}
		});
	       }
    }
   
   
   
//退出登录
function loginout() {
	$.ajax({
		url: urlcore + "/api/login/logout",
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				//window.location.href="login.html";
			} else {
				alert("退出未成功！");
			}
		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});
}

   
   
function toLogin(phone, password) {
	if(phone != "" && password != "") {
		$.ajax({
			url: urlcore + "/api/login/loginPhoneweixin",
			type: "POST",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			data: JSON.stringify({
				phone: phone,
				password: password
			}),
			success: function(da) {
				if(da.success == true) {
					
					//alert(JSON.stringify(da.data.data.id));
				/*	console.log(da.data.id);
                   console.log(da.data);
                   	console.log(da.data.id);*/
					//设置cookie
					var domain_url = urlcore.split('://')[1];
					if(domain_url.indexOf(':') > -1) {
						domain_url = domain_url.split(':')[0];
					} else {
						domain_url = domain_url.split('/')[0];
					}
	document.cookie = "sid=" + da.data.data.token + ";path=/;domain=" + domain_url;
				// alert(document.cookie);
			window.location.href = "../index.html";
				}else{
					alert(da.msg);
				}
			},
			error: function() {
				/* Act on the event */
				alert("error");
			}
		});
	}
}
   
   
 function quedinganniu(){
 	var phone=$("#phone").val();
  	  var code=$("#code").val();
    	 if (!(/^1(3|4|5|7|8)\d{9}$/.test(phone))){ 
	            	alert("手机号码有误");
	            	return;
	       }else{
	       	$.ajax({
             url: urlcore + "/api/user/updatePhone2?phone="+phone+"&code="+code+"&userId="+uuuuid,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
                   window.location.href="../gotoindex.html";
				} else {
				alert(data.msg);
				}
			},
			error: function() {
				alert("error");
			}
		});
	       }
    	
    }
   
